package us.kg.kotoriforest.spring.condition;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.util.Objects;

/**
 * Windows系统条件
 *
 * @author Kotori rotroutine@163.com
 * @since 2025/1/24
 */
public class WindowsCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        // context是IOC容器的上下文
        // return System.getProperty("os.name").toLowerCase().contains("windows");
        return Objects.requireNonNull(context.getEnvironment().getProperty("OS")).toLowerCase().contains("windows");
    }
}
